<%@page import="Data.Comment"%>
<%@page import="Data.Member"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="Data.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Data.Event"%>
<section id="content" class="gray-area">
    <div class="container car-detail-page">
        <div class="row">
            <div id="main" class="col-md-9">
                <%
                    if (request.getParameter("EventID") != null) {
                        Event ct = new Event();
                        int eventID = Integer.parseInt(request.getParameter("EventID"));
                        ArrayList<Event> a = ct.ESelectByID(eventID);
                        if (a.size() > 0) {
                            for (int i = 0; i < a.size(); i++) {
                                Event event = a.get(i);
                                SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
                                out.print("<input type='hidden' name='txtEventID' id='txtEventID' value='" + event.getEventID() + "' />");

                %>
                <div class="featured-image box">
                    <% out.print("<img src='../uploads/" + event.getImages() + "' style='height:500px' alt='' />");%>
                </div>
                <div class="tab-container">
                    <ul class="tabs">
                        <li class="active">
                            <a  data-toggle="tab">Details</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div style="min-height: 300px;" class="tab-pane fade in active" id="car-details">
                            <!--detail-->

                            <table width='100%' border='0' style="font-size: 18px;"  cellspacing='14' cellpadding='14'>

                                <tr>
                                    <td height="40" width='20%'>EventName:</td>
                                    <%out.print("<td>" + event.getEventName() + "</td>");%>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>Speakers:</td>
                                    <%out.print("<td>" + event.getSpeakers() + "</td>");%>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>Address:</td>
                                    <%out.print("<td>" + event.getAddress() + "</td>");%>
                                </tr>
                                <tr>
                                    <td  height="40" width='20%'>Contents:</td>
                                    <%out.print("<td>" + event.getContents() + "</td>");%>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>Price:</td>
                                    <%
                                        if (event.getPrice() == 0.0) {
                                            out.print("<td style='color:red'>Free</td>");
                                        } else {
                                            out.print("<td style='color:red'>$" + event.getPrice() + "</td>");
                                        }
                                    %>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>TimeEvent:</td>
                                    <%out.print("<td>" + event.getTimeEvent() + "</td>");%>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>Deadline:</td>
                                    <%out.print("<td>" + event.getDeadline() + "</td>");%>
                                </tr>
                                <tr>
                                    <td height="40" width='20%'>&nbsp;</td>
                                    <td height="40" width=''>&nbsp;</td>

                                </tr>                                <tr>

                                    <td height="40" width='20%'>&nbsp;</td>
                                    <%out.print("<td> <a href='index.jsp?page=EnrollEvent&EventID=" + event.getEventID() + "' style='background:  #00A8FF;  width: 120px; height: 40px; float: left; text-align: center; padding-top: 10px; font-size: 16px; color: #fff;'>EnrollEvent</a></td>");%>

                                </tr>
                            </table>

                        </div>
                        <!--comment-->
                        <div style="width: 100%;  min-height: 100px;background: #edeff4; border-top: 1px solid #ccc;">
                            <%
                                Comment cmt = new Comment();
                                int count = 0;
                                ArrayList<Comment> countCmt = cmt.CmtselectByEventID(event.getEventID());
                                if (countCmt.size() > 0) {
                                    for (int Ccmt = 0; Ccmt < countCmt.size(); Ccmt++) {
                                        count++;
                                    }
                                }
                                out.print("<span style='color: #3b5998; margin-left: 23px; font-size: 14px; float: left; padding: 10px 0 10px 0'>Total: " + count + " comment.</span>");
                            %>

                            <hr style="margin: 0 0 0 23px; width: 95%;border: 0; background: #ccc; height: 1px"/>
                            <form action="../CommentPR" method="post" style="font-size: 14px;" name="frmCmt">

                                <table border="0" style="margin: 5px 10px 0 23px ;width: 95%;">
                                    <%
                                        ArrayList<Comment> acmt = cmt.CmtselectByEventID(event.getEventID());
                                        if (acmt.size() > 0) {
                                            for (int icmt = 0; icmt < acmt.size(); icmt++) {
                                                Comment lscmt = acmt.get(icmt);

                                                Member m = new Member();
                                                ArrayList<Member> mb = m.MselectById(lscmt.getMemberID());
                                                for (int u = 0; u < mb.size(); u++) {
                                                    Member ma = mb.get(u);
                                                    //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
                                                    String datecmt = lscmt.getDatecomment();


                                    %>
                                    <tr>
                                        <td width="5%" rowspan="2" valign="top"><img style="margin: 0 5px 5px 0"  width="35" height="35" src="../client/images/cmtNam.jpg" alt="cmt" /></td>
                                        <td>
                                            <% out.print("<b style='color: #3b5998;'>" + ma.getMemberName() + "</b>");%>
                                            <% out.print("<span>" + lscmt.getContents() + "</span>");%>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><span style="color: #9197a3;font-size: 11px;" ><% out.print(datecmt);%></span></td>
                                    </tr>
                                    <%}
                                            }
                                        }%>
                                </table>
                                <table border="0" style="margin: 5px 10px 0 23px; width: 97%;">
                                    <tr>
                                        <td width="5%" valign="top"><img  width="35" height="35" src="../client/images/cmtNam.jpg" alt="cmt" /></td>
                                        <td>
                                            <%
                                                if (session.getAttribute("ssusercl") != null) {
                                                    String user = (String) session.getAttribute("ssusercl");
                                                    if (user == "") {
                                                    } else {
                                                        Member mem = new Member();
                                                        ArrayList<Member> pm = mem.MselectByquery("SELECT * FROM Member where Username='" + user + "'");
                                                        if (pm.size() > 0) {
                                                            for (int im = 0; im < pm.size(); im++) {
                                                                Member paym = pm.get(im);

                                                                out.print("<input type='hidden' name='txtEventID' id='txtEventID' value='" + event.getEventID() + "' />");
                                                                out.print("<input type='hidden' name='txtMemComment' id='txtMemComment' value='" + paym.getMemberID() + "' />");
                                                            }
                                                        }
                                                    }
                                                } else {
                                                }
                                            %>
                                            <input style="margin:3px 5px 10px 0; height: 30px; width: 90%" type="text" placeholder=" Enter comment..." name="txtComment" />
                                            <input style="height: 30px; width: 55px" type="submit" name="btnComment" value="Send" />
                                        </td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
                <%}
                        }
                    }%>
            </div>
            <jsp:include page="menu-right.jsp" />
        </div>
    </div>
</section>